package com.xjscrm.console.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xjscrm.console.dto.chat.ChatTalkSessionQueryDTO;
import com.xjscrm.console.entity.ChatTalkSession;
import com.xjscrm.console.vo.chat.ChatTalkSessionDeviceVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author mingyang.chen create in 2024/4/1 17:43
 */
@Mapper
public interface ChatTalkSessionMapper extends CommonMapper<ChatTalkSession> {
    int deleteByPrimaryKey(Long id);

    int insertSelective(ChatTalkSession record);

    ChatTalkSession selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(ChatTalkSession record);

    List<ChatTalkSession> selectByDeviceUniqueId(@Param("merId") Long merId, @Param("deviceUniqueId") Long deviceUniqueId);

    ChatTalkSession select(@Param("param") ChatTalkSessionQueryDTO query);

    List<ChatTalkSession> page(Page<ChatTalkSession> page, @Param("param") ChatTalkSessionQueryDTO query);

    ChatTalkSession selectByConversationId(@Param("merId") Long merId, @Param("conversationId") String conversationId,
                                           @Param("deviceUniqueId") Long deviceUniqueId);

    ChatTalkSession selectByConversationIdAndDeviceId(@Param("merId") Long merId, @Param("conversationId") String conversationId,
                                                      @Param("deviceId") String deviceId);

    List<ChatTalkSessionDeviceVO> selectShieldCountWithDeviceUniqueId(Long merId);

    List<ChatTalkSession> selectByIds(@Param("merId") Long merId, @Param("ids") List<Long> ids);

    int existsByConversationName(@Param("merId") Long merId, @Param("deviceUniqueId") Long deviceUniqueId, @Param("conversationId") String conversationId);

    List<ChatTalkSession> selectListByConversationIds(@Param("merId") Long merId, @Param("deviceUniqueId") Long deviceUniqueId, @Param("conversationIds") List<String> conversationIds);

    int selectExistsByName(@Param("merId") Long merId, @Param("deviceUniqueId") Long deviceUniqueId, @Param("conversationName") String conversationName);

    List<Long> selectListIdsWithOrderSessionExcludeId(@Param("merId") Long merId, @Param("staffId") Long staffId,
                                                      @Param("deviceUniqueId") Long deviceUniqueId);
}